package cn.seaboot.admin.logger.service;

import cn.seaboot.admin.logger.bean.ServiceLog;
import cn.seaboot.admin.logger.dao.ServiceLogDao;
import cn.seaboot.commons.core.UUIDUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
* Service
* 方法调用日志 [t_sys_log_service]
* @author Mr.css on 2018-6-20
*/
@Service
public class ServiceLogService {

    @Resource
    private ServiceLogDao serviceLogDao;

    /**
     * 增
     *
     * @param pojo pojo
     * @return affected rows
     */
    public int insert(ServiceLog pojo){
        pojo.setId(UUIDUtils.genUUID32());
        pojo.setGmtCreate(LocalDateTime.now());
        return serviceLogDao.insert(pojo);
    }

    /**
     * 删
     *
     * @param id id
     * @return affected rows
     */
    public int deleteById(String id){
        return serviceLogDao.deleteById(id);
    }

    /**
     * 改
     *
     * @param pojo pojo
     * @return affected rows
     */
    public int updateById(ServiceLog pojo) {
        return serviceLogDao.updateSampleById(pojo);
    }

    /**
     * 查
     *
     * @param id id
     * @return pojo
     */
    public ServiceLog queryById(String id){
        return serviceLogDao.selectById(id);
    }

    /**
     * 查列表
     *
     * @param params 参数
     * @return list
     */
    public List<ServiceLog> queryList(Map<String, Object> params) {
        return serviceLogDao.selectList(params);
    }
}
